package designpattern.structural_patterns;

public class ProxyPattern {
	/**
	 * Pattern nay` duoc. dung` voi' Java RMI
	 * @author tandaica0612
	 *
	 */
	interface Subject{
		void request();
	}
	public class RealSubject implements Subject{
		@Override
		public void request() {
			System.out.print("RealSubject\n");
		}
	}
	public class Proxy implements Subject{
		Subject subject;
		@Override
		public void request() {
			subject = new RealSubject();//--> use RealSubject 
			subject.request();
		}
	}
	public static void main(String[] args) {
		ProxyPattern proxyPattern = new ProxyPattern();
		//Dung` proxy de? lay' doi' tuong.
		Subject proxy = proxyPattern.new Proxy();
		proxy.request();
		//Dung truc. tiep doi' tuong that.
		Subject subject = proxyPattern.new RealSubject();
		subject.request();
	}

}
